package Practice;

import java.util.Scanner;

public class StudentId {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(),m = sc.nextInt();
        int[] arr = new int[n];
        int x = 0;
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        for (int i = 0; i < m; i++) {
            x = sc.nextInt();
            x--;
            System.out.println(arr[x]);
        }
    }
}
